﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace S4Store.Models.Chart
{
    public class Color
    {
        public static String Blue = "#56a7b8";
        public static String Green = "#84bc5b";
        public static String Red = "#f2765e";
        public static String Yellow = "#f9be64";
        public static String LightBlue = "#24CBE5";
        public static String LightGreen = "#64E572";
        public static String LightRed = "#FF9655";
        public static String LightYellow = "#FFF263";

        public static String Target = Green;
        public static String Actual = Blue;

        public static String[] DefautColors = new String[] { Blue, Green, Red, Yellow, LightBlue, LightGreen, LightRed, LightYellow };
    }

    public class Line
    {
        public Line()
        {
            Serieses = new List<ChartSeries>();
            XAxis = new List<string>();
            IsRate = true;
            Colors = Color.DefautColors.ToList();
        }

        public bool IsRate { get; set; }
        public String Name { get; set; }
        public String YAxis { get; set; }
        public List<String> XAxis { get; set; }
        public List<ChartSeries> Serieses { get; set; }
        public int? Width { get; set; }
        public int? Height { get; set; }
        public List<String> Colors { get; set; }
    }

    public class Column
    {
        public Column()
        {
            Serieses = new List<ChartSeries>();
            XAxis = new List<string>();
            IsRate = true;
            IsNegative = false;
            Colors = Color.DefautColors.ToList();
        }
        public bool IsNegative { get; set; }
        public bool IsRate { get; set; }
        public String Name { get; set; }
        public String YAxis { get; set; }
        public List<String> XAxis { get; set; }
        public List<ChartSeries> Serieses { get; set; }
        public int? Width { get; set; }
        public int? Height { get; set; }
        public List<String> Colors { get; set; }
    }


    public class Pie
    {
        public Pie()
        {
            IsRate = true;
            Data = new Dictionary<string, decimal>();
        }

        public bool IsRate { get; set; }
        public String Name { get; set; }
        public String YAxis { get; set; }
        public int? Width { get; set; }
        public int? Height { get; set; }
        public Dictionary<String,decimal> Data{get;set;}
        public string Unit { get; set; }
    }

    public class ChartSeries
    {
        public ChartSeries()
        {
            Data = new List<decimal>();
        }
        public ChartSeries(String name)
        {
            Name = name;
            Data = new List<decimal>();
        }
        public String Name { get; set; }
        public List<decimal> Data { get; set; }
        public int Precision = 1;

        public List<String> FormatData
        {
            get
            {
                List<String> data = new List<string>();
                foreach (var d in Data)
                {
                    data.Add(d.toInt(Precision));
                }
                return data;
            }
        }
    }
}